package com.bigwolf.gateway.config;


import com.alibaba.csp.sentinel.adapter.gateway.sc.callback.GatewayCallbackManager;
import jakarta.annotation.PostConstruct;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.server.ServerResponse;

@Configuration
public class SentinelConfig {
//    @Bean(name = "sentinel-json-gw-flow-converter")
//    public JsonGatewayFlowRuleListConverter jsonGatewayFlowRuleListConverter() {
//        return new JsonGatewayFlowRuleListConverter();
//    }

    @PostConstruct
    public void init() {
        GatewayCallbackManager.setBlockHandler((exchange, ex) ->
                ServerResponse.status(429)
                        .bodyValue("请求超过最大数，请稍候再试2"));
    }
}